package com.erlin.common.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.Serializable;

@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "aliyun.oss")
public class OssConfig implements Serializable {
    @Value("endpoint")
    private String endpoint;
    @Value("accesskey-id")
    private String accesskeyId;
    @Value("accesskey-secret")
    private String accesskeySecret;
    @Value("bucket")
    private String bucket;
    @Value("folder")
    private String folder;
    @Value("download-url")
    private String downloadUrl;
    @Bean
    public OSS ossClient(){
        return new OSSClient(endpoint,accesskeyId,accesskeySecret);
    }
}
